/**
 * Copyright:Copyright(c)2014-2017
 * Company:厦门市易致达物联网科技有限公司
 * @version 1.0
 */
package shop.controller.manage.proxytestproject;
import shop.core.common.bean.JSONResult;
import shop.core.util.KeyValueHelper;
import shop.core.Services;
import shop.core.util.MD5;
import shop.services.manage.proxytestproject.ProxytestprojectService;
import shop.services.manage.proxytestproject.bean.Proxytestproject;
import shop.core.BaseController;
import shop.core.RequestHolder;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @类名称：ProxytestprojectAction
 * @创建人：wzl
 * @创建时间：2018-05-25 上午09:56:57
 * @版本号：1.0
 * @描述：
 */
@Controller
@RequestMapping("/manage/proxytestproject/")
public class ProxytestprojectAction extends BaseController<Proxytestproject> {
    private static final Logger logger = LoggerFactory.getLogger(ProxytestprojectAction.class);
    @Autowired
    private ProxytestprojectService proxytestprojectService;
    private static final String page_toList = "/manage/proxytestproject/proxytestprojectList";
    public ProxytestprojectService getService() {
        return proxytestprojectService;
    }

    private ProxytestprojectAction(){
        super.page_toList = page_toList;
        super.page_toAdd = null;
        super.page_toEdit = null;
    }

    /**
     * 批量添加检测项目
     *
     * @return jsonResult
     * @throws Exception
     */
    @RequestMapping(value = "insertTestProjects", method = RequestMethod.POST)
    @ResponseBody
    public JSONResult insertTestProjects(@RequestParam(value = "ids[]") String[] ids,Proxytestproject proxytestproject) throws Exception {
        JSONResult jsonResult = new JSONResult();
        for(int i=0;i<ids.length;i++){
            proxytestproject.setTestProjectID(ids[i]);
            proxytestprojectService.insert(proxytestproject);
        }
        return jsonResult;
    }

    /**
     * 删除未保存的检测项目
     *
     * @return jsonResult
     * @throws Exception
     */
    @RequestMapping(value = "deleteTestProjects", method = RequestMethod.POST)
    @ResponseBody
    public JSONResult deleteTestProjects(){
        JSONResult jsonResult = new JSONResult();
        proxytestprojectService.deleteTestProjects();
        return jsonResult;
    }

    /**
     * 查询未保存的检测项目
     *
     * @return
     * @throws Exception
     */
    @RequestMapping("selectTestProjectList")
    @ResponseBody
    public JSONResult selectTestProjectList(){
        List<Proxytestproject> rsList = proxytestprojectService.selectTestProjectList();
        JSONResult jsonResult = new JSONResult();
        jsonResult.setData(rsList);
        return jsonResult;
    }


}
